package com.mos.dao.impl;

import com.mos.base.sql.BaseDaoImpl;
import com.mos.dao.AccessoryDao;
import com.mos.entity.Accessory;
import org.springframework.stereotype.Repository;

/**
 * Package Name: com.mos.dao.impl
 * User: grq
 * Date: 2016/4/7
 * Time: 14:50
 * Description:some des here!
 */
@Repository
public class AccessoryDaoImpl extends BaseDaoImpl implements AccessoryDao {

    public int add(Accessory accessory) {
        String sql = "insert into t_accessory(id,type,originalName,path,size,createTime,createrId,updateTime,updaterId)" +
                " values (?,?,?,?,?,?,?,?,?)";
        Object[] params = new Object[]{accessory.getId(), accessory.getType(), accessory.getOriginalName(),
                accessory.getPath(), accessory.getSize(), accessory.getCreateTime(), accessory.getCreaterId(),
                accessory.getUpdateTime(), accessory.getUpdaterId()};
        return super.addOrUpdateOrDelete(sql,params,Accessory.class);
    }

    public int deleteById(String id) {
        String sql = "delete from t_accessory where id = ? ";
        Object[] params = new Object[]{id};
        return super.addOrUpdateOrDelete(sql,params,null);
    }

    public Accessory getById(String id) {
        String sql = "select * from t_accessory where id = ? ";
        Object[] params = new Object[]{id};
        return super.findForObject(sql,params,Accessory.class);
    }

}
